package com.zr.mapper;

import com.zr.dto.approval.QueryDetailReqDto;
import com.zr.dto.approval.UpdateFlowReqDto;
import com.zr.dto.staff.StaffDetailInfoRequest;
import com.zr.entity.Menu;
import com.zr.entity.Staff;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import tk.mybatis.mapper.common.Mapper;

import java.util.List;

/**
 * @author:
 * @date: 2019/11/14 20:49
 * @description: com.zr.mapper
 * @version: 1.0
 */

public interface StaffMapper extends Mapper<Staff> {

    /**
     * 批量新增员工信息
     * @param staffList
     * @return
     */
    int insertStaffList(@Param("staffList") List<Staff> staffList);

    /**
     * 获取所有一级父菜单
     * @return
     */
    List<Menu> getParentMenus(@Param("roleId") Integer roleId);

    /**
     * 根据父菜单id获取所有子菜单
     * @param id
     * @return
     */
    List<Menu> getChildMenusByParentId(@Param("id") Integer id);

    /**
     * 根据身份证号查询员工信息
     * @param identificationNum
     * @return
     */
    Staff selectByIdentificationNum(@Param("identificationNum") String identificationNum);


    /**
     * 根据id批量查询
     * @param
     * @return
     */
    @Select({
            "<script>" +
                    "select * from t_staff where id in " +
                    "<foreach item = 'item' index = 'index' collection = 'dto.staffIdList' open='(' separator=',' close=')'>" +
                    "#{item}" +
                    "</foreach>"+
                    "limit  #{offSet} ,#{size}"+

                    "</script>"})
    List<Staff> selectBatchPageByIds(@Param("dto") QueryDetailReqDto dto, @Param("offSet") Integer offSet, @Param("size") Integer size);

    @Select({
            "<script>" +
                    "update t_staff set status =#{status} where id in " +
                    "<foreach item = 'item' index = 'index' collection = 'staffIdList' open='(' separator=',' close=')'>" +
                    "#{item}" +
                    "</foreach>"+
                    "</script>"})
    void updateBatchPageByIds(UpdateFlowReqDto data);

    List<Staff> selectById(Long id);

    /**
     * 根据ID查询员工信息
     * @param staffDetailInfoRequest
     * @return
     */
    Staff getInfoById(StaffDetailInfoRequest staffDetailInfoRequest);

    List<Staff> getAll();
}
